package cn.xabad.commons.sample.ui.commons;

import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
import cn.xabad.commons.sample.SampleApplication;
import cn.xabad.commons.tools.PreferenceU;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

// +----------------------------------------------------------------------
// | CreateTime: 15/8/12 
// +----------------------------------------------------------------------
// | Author:     xab(http://www.xueyong.net.cn)
// +----------------------------------------------------------------------
// | CopyRight:  http://www.boxfish.cn
// +----------------------------------------------------------------------
public abstract class BasePresenterImp {
    protected Context context ;
    protected PreferenceU preferenceU ;
    public BasePresenterImp() {
        this.context = SampleApplication.context();
        this.preferenceU = PreferenceU.getInstance(this.context);
    }

    protected <T> Observable.Transformer<T, T> applyIoSchedulers() {
        return observable -> observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    protected String getString(int resId){
        return context.getString(resId);
    }
    protected Resources getString( ){
        return context.getResources();
    }

    protected AssetManager getAssets(){
        return context.getAssets();
    }
}
